#include "bsp_wdog.h"
#include "../uart/bsp_uart.h"
#include "../../stdio/include/stdio.h"

void WDOG_Init(WDOG_Type *base) {
  // 使能时钟
  CCM->CCGR3 |= (0x3 << 16);
  // 设置冷启动
  SRC->SCR &= ~(0x1 << 0);
  // 关闭看门狗
  base->WCR &= ~(0x1 << 2);
  // 设置超时时间
  base->WCR |= (18 << 8);
  // 打开看门狗
  base->WCR |= (0x1 << 2);
}

void WDOG_Servering(WDOG_Type *base) {
  base->WSR = 0x5555;
  printf("WDOG\r\n");
  base->WSR = 0xAAAA;
}